/**
 * 
 */
package com.vanstone.imgapp.common.serial;

import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;

import com.esotericsoftware.kryo.Kryo;

/**
 * @author shipeng <br />
 * 
 */
public class KryoFactory extends BasePooledObjectFactory<Kryo> {

  @Override
  public Kryo create() throws Exception {
    Kryo kryo = new Kryo();
    kryo.setReferences(true);
    kryo.setRegistrationRequired(false);
    return kryo;
  }

  @Override
  public PooledObject<Kryo> wrap(Kryo kryo) {
    return new DefaultPooledObject<Kryo>(kryo);
  }

}
